package com.frost.blog.mapper;

import com.frost.blog.model.BlogInfo;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface BlogMapper {
    // 查询博客列表
    @Select("select * from blog where delete_flag = 0 order by create_time desc")
    List<BlogInfo> selectAllBlog();

    // 根据博客id查询博客详情
    @Select("select * from blog where id = #{id}")
    BlogInfo selectById(Integer id);

    // 根据博客id修改博客，包括修改和删除
    Integer updateBlog(BlogInfo blogInfo);

    // 插入博客
    @Insert("insert into blog (title, content, user_id) value (#{title}, #{content}, #{userId})")
    Integer insertBlog(BlogInfo blogInfo);
}
